<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>系统后台 - {$Think.config.INTENDANT_NAME} - by HemaCMS</title>
    <link href="__INTENDANT__/css/admin_style.css" rel="stylesheet" />
    <script src="__COMMON__/jquery.js"></script>
    <script src="__COMMON__/jquery.cookie.js"></script>
    <script src="__COMMON__/layer/layer.js"></script>
    <script src="__INTENDANT__/js/iteny.intendant.js"></script> <!-- 公共easyui JS -->
    <link href="__INTENDANT__/css/icons.css" rel="stylesheet" />
    <link href="__INTENDANT__/css/iteny.css" rel="stylesheet" />
    <style type="text/css">
    .org-2{
    	background: #cdcdcd;
		border-radius: 2px;
		border: 1px solid #b5b5b5;
		color: #fff;
		display: inline-block;
		font-size: 14px;
		font-style: normal;
		height: 18px;
		line-height: 18px;
		margin-right: 5px;
		text-align: center;
		width: 18px;
		background: #ff8f2c;
		border-color: #f4791f;
    }
    .tree-file{margin-right: 5px;}
    </style>
</head>
<body>
<div class="wrap J_check_wrap">
	<div class="nav">
	    <ul class="cc">
	        <li class="current"><a href="{:U('Site/menu')}">菜单设置</a></li>
	        <li><a href="{:U('Site/addMenu')}">添加菜单</a></li>
	    </ul>
	</div>
  <form class="J_ajaxForm" action="{:U('Site/sortMenu')}" method="post">
    <div class="table_list">
      <table width="100%">
        <colgroup>
        <col width="40">
        <col width="40">
        <col width="270">
        <col width="170">
        <!-- <col width="100">
        <col width="50"> -->
        <col width="80">
        <col width="160">
        </colgroup>
        <thead>
          <tr>
            <td align="center">排序</td>
            <td align="center">ID</td>
            <td align="left">菜单名称</td>
            <td align="center">菜单规则</td>
           <!--  <td align="center">条件</td> -->
            <!-- <td align="center">状态</td> -->
            <td align="center">是否显示</td>
            <td align="center">管理操作</td>
          </tr>
        </thead>
        <tbody>
        	<volist name="menu" id="vo">
        	<tr>
        		<td align="center"><input style="text-align: center" name="sort[{$vo.id}]" type="text" size="3" value="{$vo.sort}" class="input"></td>
        		<td align="center">{$vo.id}</td>
        		<td>{:str_repeat('&nbsp;&nbsp;&nbsp;',$vo['level'])}<if condition='$vo["level"] gt 0'></if>{$vo.html}<span class="tree-icon tree-file {$vo.icon}"></span><!-- <i class="org-2"><?php echo $vo['level']+1; ?></i> -->{$vo.title}</td>
        		<td align="center">{$vo.name}</td>
        		<!-- <td>{$vo.condition}</td>
        		<td align="center"><if condition='$vo["status"] eq 1'><span class="greens">显示</span><else /><span class="reds">不显示</span></if></td> -->
        		<td align="center"><if condition='$vo["isshow"] eq 1'><span class="greens">显示</span><else /><span class="reds">不显示</span></if></td>
        		<td align="center"><a class="J_add" href="{:U('Site/addMenu','parentid=' . $vo["id"])}" data="{$vo.level}">添加子菜单</a> | <a class="J_edit" href="{:U('Site/editMenu','id=' . $vo["id"])}">修改</a> | <a class="J_ajax_del" datatitle="{$vo.title}" href="{:U('Site/delMenu')}" data="{$vo.id}">删除</a> </td>
        	</tr>
        	</volist>
        </tbody>
      </table>
      <!-- <div class="p10"><div class="pages"> {$Page} </div> </div> -->

    </div>
    <div class="btn_wrap">
      <div class="btn_wrap_pd">
        <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">排序</button>
      </div>
    </div>
  </form>
</div>
<script type="text/javascript">
$(function(){
	$('.J_ajax_del').on('click', function (e) {
		e.preventDefault();
		var title = $(this).attr('datatitle');
		var href = $(this).attr('href');
		var data = $(this).attr('data');
		layer.confirm('是否删除菜单<span style="color:red;">['+title+']</span>及下属的所有菜单', {icon: 3,offset:'200px', title:'删除菜单提示'}, function(index){


	    	layer.close(index);
	    	$.ajax({
				type: 'post',
				url: href,
				data : {id : data},
				dataType:"json",
				beforeSend: function(){
					layer.load(1);
				},
				success: function(data){
					layer.close(layer.load(1));
					if(!data.status){
						ITENY.alert('提示信息',data.info,2,'3000');

					} else {
						ITENY.alert('提示信息',data.info,1,'3000');
						setTimeout(function(){
			                ITENY.reloadPage(window);
			            },3000);

					}
				},
				error: function(data){
					layer.close(layer.load(1));
					ITENY.alert('提示信息',data.responseText,1,'3000');

				}
			});
		});
	});
	$('.J_add').on('click', function (e) {
		var data = $(this).attr('data');
		if(data >= 3){e.preventDefault();ITENY.alert('提示信息','对不起，菜单最多4级！',2,'3000');}
	});
	// $('.J_edit').on('click', function (e) {
	// 	var ss = '{$ss}';
	// 	if(ss == 'true'){e.preventDefault();ITENY.alert('提示信息','对不起，菜单最多4级！',2,'3000');}
	// });
	$('button.J_ajax_submit_btn').on('click', function (e) {
		e.preventDefault();
		var btn = $(this),
        form = btn.parents('form.J_ajaxForm');
        if(btn.attr("disabledSubmit")){
	        btn.text('请勿重复提交...').prop('disabled', true).addClass('disabled');
	        return false;
	    }
		btn.attr("disabledSubmit",true);
    	var param = form.serialize();
    	$.ajax({
			url: form.attr('action'),
			dataType:'json',
			type:'POST',
			data:param,
			beforeSend: function(){
				layer.load(1);
			},
			success: function(data){
				layer.close(layer.load(1));
				if(!data.status){
					ITENY.alert('提示信息',data.info,2,'3000');

				} else {
					ITENY.alert('提示信息',data.info,1,'3000');
					setTimeout(function(){
		                ITENY.reloadPage(window);
		            },3000);

				}
			},
			error: function(data){
				layer.close(layer.load(1));
				ITENY.alert('提示信息',data.responseText,1,'3000');

			}
		});
	});
});
</script>
</body>
</html>